import { join } from 'path';
import { diskStorage } from 'multer';
import { registerAs } from '@nestjs/config';
// import * as moment from 'moment';

export default registerAs('file', () => ({
  root: join(process.cwd(), './uploads'),
  storage: diskStorage({
    destination: join(process.cwd(), `./uploads`),
    filename: (req, file, cb) => {
      const filename = `${new Date().getTime()}.${file.mimetype.split('/')[1]}`;
      return cb(null, filename);
    },
  }),
}));
